#ifndef __B5618552_1830_4b32_AE29_6631701EB6B1__
#define __B5618552_1830_4b32_AE29_6631701EB6B1__

#include "../import/head.h"
#include "../tools/head.h"

/////////////////////////////////////////////////////////////////////////////////////////
// 

namespace xos
{
    // 
    // crt_impl
    // 
    class crt_impl : public xos_stl::mem_pool_item< crt_impl, thread_lock >,
        public i_crt
    {
    public:
        crt_impl();
        ~crt_impl();

    public:
        int init();
        int term();

    public:
        const char * strrstr( const char * lpszStr, const char * lpszSubStr, bool bCaseSensitive );
        const char * strstr( const char * lpszStr, const char * lpszSubStr, bool bCaseSensitive );

        char * strrstr( char * lpszStr, const char * lpszSubStr, bool bCaseSensitive );
        char * strstr( char * lpszStr, const char * lpszSubStr, bool bCaseSensitive );

        const char * strrchr( const char * lpszStr, char c );
        const char * strchr( const char * lpszStr, char c );

        char * strrchr( char * lpszStr, char c );
        char * strchr( char * lpszStr, char c );

        int vsnprintf( char * lpszBuf, int nLen, const char * format, va_list argptr );
        int sprintf( char * buf, int nLen, const char * lpszFormat, ... );
        int gets( char * lpszBuf, int nLen );

        double atof( const char * lpszStr );
        xos_i64 atoi64( const char * lpszStr );
        int atoi( const char * lpszStr );

        // 
        // nLen include the last '\0'
        // 
        char * strncpy( char * lpszDst, int nLen, const char * lpszSrc );
        char * strcpy( char * lpszDst, const char * lpszSrc );

        char * strcat( char * lpszDst, const char * lpszSrc );
        int strlen( const char * lpszStr );

        int stricmp( const char * lpszStr1, const char * lpszStr2 );
        int strcmp( const char * lpszStr1, const char * lpszStr2 );

        int assert_valid( bool bAssert );

        // 
        // if uSeed is 0, sys will add seed
        // 
        int srand( xos::xos_u32 uSeed );
        int rand( int nMax );

        // 
        // release
        // 
        int release();
    };
} // xos

#endif // __B5618552_1830_4b32_AE29_6631701EB6B1__
